package com.aruba.attendance.ui.widget.datepicker

import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.listSaver
import androidx.compose.runtime.saveable.rememberSaveable
import kotlinx.coroutines.delay

/**
 * Created by aruba on 2023/3/9.
 */
@Composable
fun rememberSelectDateState(
    lazyListState: LazyListState = rememberLazyListState(),
    scrollAnime: MutableState<Boolean> = remember { mutableStateOf(true) }
): DateListState {
    return remember { DateListState(lazyListState, scrollAnime) }
}

class DateListState(
    var lazyListState: LazyListState,
    var scrollAnime: MutableState<Boolean>,
) {

    /**
     * 没有选中动画效果的滚动
     */
    suspend fun noAnimeScrollToIndex(index: Int, itemSize: Int) {
        scrollAnime.value = false
        lazyListState.scrollToItem(index + itemSize * 1000 - 1)
        delay(1000)
    }
}